home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / MoreFiles 1.2.1 / DirectoryCopy.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-30  |  6.8 KB  |  196 lines  |  [TEXT/KAHL]

  1. /*
  2. **    Apple Macintosh Developer Technical Support
  3. **
  4. **    DirectoryCopy: A robust, general purpose directory copy routine.
  5. **
  6. **    by Jim Luther, Apple Developer Technical Support
  7. **
  8. **    File:        DirectoryCopy.h
  9. **
  10. **    Copyright © 1992-1994 Apple Computer, Inc.
  11. **    All rights reserved.
  12. **
  13. **    You may incorporate this sample code into your applications without
  14. **    restriction, though the sample code has been provided "AS IS" and the
  15. **    responsibility for its operation is 100% yours.  However, what you are
  16. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  17. **    after having made changes. If you're going to re-distribute the source,
  18. **    we require that you make it clear in the source that the code was
  19. **    descended from Apple Sample Code, but that you've made changes.
  20. */
  21.  
  22. #ifndef __DIRECTORYCOPY__
  23. #define __DIRECTORYCOPY__
  24.  
  25. #ifndef __TYPES__
  26. #include <Types.h>
  27. #endif
  28.  
  29. #ifndef __ERRORS__
  30. #include <Errors.h>
  31. #endif
  32.  
  33. #ifndef __MEMORY__
  34. #include <Memory.h>
  35. #endif
  36.  
  37. #ifndef __OSUTILS__
  38. #include <OSUtils.h>
  39. #endif
  40.  
  41. #ifndef __FILES__
  42. #include <Files.h>
  43. #endif
  44.  
  45. #ifndef __MOREFILES__
  46. #include "MoreFiles.h"
  47. #endif
  48.  
  49. #ifndef __MOREFILESEXTRAS__
  50. #include "MoreFilesExtras.h"
  51. #endif
  52.  
  53. #include "MoreDesktopMgr.h"
  54.  
  55. #ifndef __FILECOPY__
  56. #include "FileCopy.h"
  57. #endif
  58.  
  59. enum
  60. {
  61.     getNextItemOp            = 1,    /* couldn't access items in this directory - no access privileges */
  62.     copyDirCommentOp        = 2,    /* couldn't copy directory's Finder comment */
  63.     copyDirAccessPrivsOp    = 3,    /* couldn't copy directory's AFP access privileges */
  64.     copyDirFMAttributesOp    = 4,    /* couldn't copy directory's File Manager attributes */
  65.     dirCreateOp                = 5,    /* couldn't create destination directory */
  66.     fileCopyOp                = 6        /* couldn't copy file */
  67. };
  68.  
  69. /*****************************************************************************/
  70.  
  71. typedef    pascal    Boolean    (*CopyErrProcPtr) (OSErr error,
  72.                                            short failedOperation,
  73.                                            short srcVRefNum,
  74.                                            long srcDirID,
  75.                                            StringPtr srcName,
  76.                                            short dstVRefNum,
  77.                                            long dstDirID,
  78.                                            StringPtr dstName);
  79. /*    ¶ Prototype for the CopyErrProc function DirectoryCopy calls.
  80.     This is the prototype for the CopyErrProc function DirectoryCopy
  81.     calls if an error condition is detected sometime during the copy.  If
  82.     CopyErrProc returns true, then DirectoryCopy attempts to continue with
  83.     the directory copy operation.  If CopyErrProc returns false, then
  84.     DirectoryCopy stops the directory copy operation.
  85.  
  86.     error            input:    The error result code that caused CopyErrProc to
  87.                             be called.
  88.     failedOperation    input:    The operation that returned an error to
  89.                             DirectoryCopy.
  90.     srcVRefNum        input:    Source volume specification.
  91.     srcDirID        input:    Source directory ID.
  92.     srcName            input:    Source file or directory name, or nil if
  93.                             srcDirID specifies the directory.
  94.     dstVRefNum        input:    Destination volume specification.
  95.     dstDirID        input:    Destination directory ID.
  96.     dstName            input:    Destination file or directory name, or nil if
  97.                             dstDirID specifies the directory.
  98.  
  99.     __________
  100.     
  101.     Also see:    DirectoryCopy, FSpDirectoryCopy
  102. */
  103.  
  104. /*****************************************************************************/
  105.  
  106. pascal    OSErr    DirectoryCopy(short srcVRefNum,
  107.                               long srcDirID,
  108.                               StringPtr srcName,
  109.                               short dstVRefNum,
  110.                               long dstDirID,
  111.                               StringPtr dstName,
  112.                               Ptr copyBufferPtr,
  113.                               long copyBufferSize,
  114.                               Boolean preflight,
  115.                               CopyErrProcPtr copyErrHandler);
  116. /*    ¶ Make a copy of a directory structure in a new location.
  117.     The DirectoryCopy function makes a copy of a directory structure in a
  118.     new location. If copyBufferPtr <> NIL, it points to a buffer of
  119.     copyBufferSize that is used to copy files data.  The larger the
  120.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  121.     routine allocates a buffer in the application heap. If you pass a
  122.     copy buffer to this routine, make its size a multiple of 512
  123.     ($200) bytes for optimum performance.
  124.     
  125.     srcVRefNum        input:    Source volume specification.
  126.     srcDirID        input:    Source directory ID.
  127.     srcName            input:    Source directory name, or nil if
  128.                             srcDirID specifies the directory.
  129.     dstVRefNum        input:    Destination volume specification.
  130.     dstDirID        input:    Destination directory ID.
  131.     dstName            input:    Destination directory name, or nil if
  132.                             dstDirID specifies the directory.
  133.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  134.                             is used the i/o buffer for the copy or
  135.                             nil if you want DirectoryCopy to allocate its
  136.                             own buffer in the application heap.
  137.     copyBufferSize    input:    The size of the buffer pointed to
  138.                             by copyBufferPtr.
  139.     preflight        input:    If true, DirectoryCopy makes sure there are
  140.                             enough allocation blocks on the destination
  141.                             volume to hold the directory's files before
  142.                             starting the copy.
  143.     copyErrHandler    input:    A pointer to the routine you want called if an
  144.                             error condition is detected during the copy, or
  145.                             nil if you don't want to handle error conditions.
  146.                             Error handling is recommended...
  147.  
  148.     __________
  149.     
  150.     Also see:    CopyErrProcPtr, FSpDirectoryCopy, FileCopy, FSpFileCopy
  151. */
  152.  
  153. /*****************************************************************************/
  154.  
  155. pascal    OSErr    FSpDirectoryCopy(const FSSpec *srcSpec,
  156.                                  const FSSpec *dstSpec,
  157.                                  Ptr copyBufferPtr,
  158.                                  long copyBufferSize,
  159.                                  Boolean preflight,
  160.                                  CopyErrProcPtr copyErrHandler);
  161. /*    ¶ Make a copy of a directory structure in a new location.
  162.     The FSpDirectoryCopy function makes a copy of a directory structure in a
  163.     new location. If copyBufferPtr <> NIL, it points to a buffer of
  164.     copyBufferSize that is used to copy files data.  The larger the
  165.     supplied buffer, the faster the copy.  If copyBufferPtr = NIL, then this
  166.     routine allocates a buffer in the application heap. If you pass a
  167.     copy buffer to this routine, make its size a multiple of 512
  168.     ($200) bytes for optimum performance.
  169.     
  170.     srcSpec            input:    An FSSpec record specifying the directory to copy.
  171.     dstSpec            input:    An FSSpec record specifying destination directory
  172.                             of the copy.
  173.     copyBufferPtr    input:    Points to a buffer of copyBufferSize that
  174.                             is used the i/o buffer for the copy or
  175.                             nil if you want DirectoryCopy to allocate its
  176.                             own buffer in the application heap.
  177.     copyBufferSize    input:    The size of the buffer pointed to
  178.                             by copyBufferPtr.
  179.     preflight        input:    If true, FSpDirectoryCopy makes sure there are
  180.                             enough allocation blocks on the destination
  181.                             volume to hold the directory's files before
  182.                             starting the copy.
  183.     copyErrHandler    input:    A pointer to the routine you want called if an
  184.                             error condition is detected during the copy, or
  185.                             nil if you don't want to handle error conditions.
  186.                             Error handling is recommended...
  187.  
  188.     __________
  189.     
  190.     Also see:    CopyErrProcPtr, DirectoryCopy
  191. */
  192.  
  193. /*****************************************************************************/
  194.  
  195. #endif
  196.